package spring_learn.a08;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
public class testController {

    @Autowired
    private ApplicationContext applicationContext;

    @GetMapping(value = "/test",produces = "text/html")
    public String test(){
        RequestBean beanForRequest =(RequestBean) applicationContext.getBean(RequestBean.class);
        SessionBean beanForSession =(SessionBean) applicationContext.getBean(SessionBean.class);
        ApplicaitonBean beanForApplication =(ApplicaitonBean) applicationContext.getBean(ApplicaitonBean.class);
        String sb = "<ul>" +
                "<li>" + "request scope:" + beanForRequest + "</li>" +
                "<li>" + "session scope:" + beanForSession + "</li>" +
                "<li>" + "application scope:" + beanForApplication + "</li>" +
                "</ul>";
        return sb;
    }
}
